(function() {
	var WordType = kiscompress.WordType;
	var SwitchVO = kiscompress.SwitchVO;
	var ScopeVO = kiscompress.ScopeVO;
	var WordVO = kiscompress.WordVO;
	var ScriptWord = kiscompress.ScriptWord;
	/*
	 * JSScript
	 * js脚本压缩类
	 * */
	function JSScript()
	{
		this._super(JSScript.super_p.constructor);
		this.connectSymbols = [];
		this.middleConnectOptions = [];
		
		this.keywords.push(
		//关键字
		"import",
		"new",
		"var",
		"let",
		"await",
		"yield",
		"async",
		"void",
		"const",
		"function",
		"public",
		"private",
		"protected",
		"static",
		"delete",
		"else",
		"switch",
		"case",
		"return",
		"for",
		"while",
		"do",
		"if",
		"on",
		"in",
		"of",
		"super",
		"extends",
		"class",
		"throw",
		"try",
		"catch",
		
		"default",
		"break",
		
		'instanceof',
		'typeof'
		);
		
		this.middleConnectOptions.push(
			//前面强制加空格的关键字
			"instanceof",
			"typeof",
			"in",
			"on",
			"of"
		);
		
		this.connectSymbols.push(
			//后面强制加空格的关键字
			"import",
			"new",
			"var",
			"await",
			"yield",
			"async",
			"void",
			"let",
			"const",
			"function",
			"public",
			"private",
			"protected",
			"static",
			"delete",
			"case",
			"else",
			"return",
			"super",
			"class",
			
			"instanceof",
			"typeof",
			"throw",
			"in",
			"on",
			"of"
		);
		
		this.connectwords.push(
			'(',
			')',
			'{',
			'}',
			'[',
			']'
		);
		
		this.exoptions.push(
		"instanceof",
		"typeof",
		
		//三字符
		'>>>',
		'<<<',
		'>>',
		'<<',
		'<<=',
		'>>=',
		'!==',
		'===',
		
		//双字符
		'+=',
		'-=',
		'*=',
		'/=',
		'<=',
		'>=',
		'%=',
		'!=',
		'~=',
		'^=',
		'&=',
		'|=',
		'&&',
		'||',
		'==',
		'--',
		'++',
		
		'(',
		')',
		'{',
		'}',
		'[',
		']',
			
		';',
		',',
		'.',
		'?',
		'=',
		'+',
		'-',
		'*',
		'/',
		'<',
		'>',
		'%',
		'!',
		'~',
		'^',
		'&',
		'|',
		':'
		);
		
		//多行注释
		this.switchs.push(new SwitchVO(0, '/*', '', ['*/'],this.checkCommon,null,WordType.CONSTANT, JSScript.JS_Commond_0, false));
		//单行注释
		this.switchs.push(new SwitchVO(1, '//', '', ['\n', '\r'],this.checkCommon,null,WordType.CONSTANT, JSScript.JS_Commond_1, false));
		//正则表达式
		this.switchs.push(new SwitchVO(2, '/', '\\', ['/'], this.checkReg,this, WordType.SYMBOL, JSScript.JS_REG, true));
		//单引号字符串
		this.switchs.push(new SwitchVO(3, "'", '\\', ['\''], null,null, WordType.CONSTANT, JSScript.JS_String_0, true));
		//双引号字符串
		this.switchs.push(new SwitchVO(4, '"', '\\', ['"'], null,null, WordType.CONSTANT, JSScript.JS_String_1, true));
		
		this.regIfKeys =  ['=', '(', ',', '[', ':'];
		this.regBreakKeys =  ['\n', '\r'];
		this.regModeKeys =  ['i', 'm', 'g'];
	}
	
	JSScript.JS_Commond_0 = 0x10000;
	JSScript.JS_Commond_1 = 0x10001;
	JSScript.JS_String_0 = 0x10002;
	JSScript.JS_String_1 = 0x10003;
	JSScript.JS_REG = 4;
	
	var b = KISU.extend(JSScript, ScriptWord);
	b.checkCommon = function(id, status,wordContent,script, index, wordList) 
	{
		if (status == 2) {
			if(wordList.length){
				if (wordContent == "[scope:window]") {
					wordList[wordList.length-1].innerKey=wordContent;
				}
				wordList[wordList.length-1].nextCRLF=true;
			}
		}
	}
	
	b.checkReg = function(id, status,wordContent,script, index, wordList) 
	{
		if (status == 0) {
			//开始
			var result = {status:1};
			if (wordContent) {
				if(this.regIfKeys.indexOf(wordContent)!=-1){
					result.status = 0;
					result.wordContent = "/";
				}
			}else if (wordList.length && this.regIfKeys.indexOf(wordList[wordList.length - 1].content) != -1) {
				result.status = 0;
				result.wordContent = "/";
			}
			return result;
		}else if(status==1){
			//中断
			if (this.regBreakKeys.indexOf(script.charAt(index))!=-1) {
				return {status:1}
			}
		}else if(status==2){
			//结束
			var i = 1;
			var mode = "";
			while (1) {
				var char = script.charAt(index+i);
				if (this.regModeKeys.indexOf(char) != -1) {
					mode += char;
				}else {
					break;
				}
				i++;
			}
			if (mode) {
				return {status:0,offset:i-1,wordContent:wordContent+"/"+mode}
			}else {
				return {status:0,wordContent:wordContent+"/"}
			}
		}
		return null;
	}
	
	b.getSortNameByID=function(id) {
		var str = "";
		var shang = id;
		do {
			var yushu = shang % 54;
			if (yushu == 0) {
				str = "_"+str;
			}
			else if (yushu == 1) {
				str = "$"+str;
			}
			else if (yushu<28){
				str = String.fromCharCode(97+yushu-2)+str;
			}
			else if (yushu <54) {
				str = String.fromCharCode(65+yushu-28)+str;
			}
		}while (shang = Math.floor(shang / 54));
		return str;
	}
	
	b.compress = function(script,unshort) {
		var wordList = this.getWords(script);
		var topso = new ScopeVO();
		topso.scopeType = ScopeVO.SCOPE_MAIN;
		topso.bigStaCount = 1;
		topso.params = [];
		wordList = this.analyseScope(wordList,0,topso);
		topso.bigEndCount = 1;
		
		if(!unshort){
			//不能使用的全局变量名
			var nousename_arr = [];
			var l = topso.params.length;
			for (var i = 0; i < l; i++) 
			{
				var word = topso.params[i].content;
				if(word){
					nousename_arr.push(word);
				}
			}
			
			this.shortTmpName(topso,wordList,0,nousename_arr);
		}
		return this.join(wordList);
	}
	
	/**
	只去掉注释字符
	*/
	b.onlyDeleteCommandString = function(script) {
		this.exoptions.length = 0;
		this.connectwords.length = 0;
		this.connectSymbols.length = 0;
		this.middleConnectOptions.length = 0;
		this.keywords.length = 0;
		this.whitespace.length = 0;
		this.whitespace.push(
			' ',
			'\t'
		);
		var wordList = this.getWords(script);
		return this.joinNormal(wordList);
	}
	
	/*
	 * 插入分号
	 * */
	b.addConlion=function(wordlist, index, count) {
		if(count==undefined)count=1;
		var w = new WordVO();
		w.content = ";";
		w.type = WordType.OPTION;
		for (var i = 0; i < count; i++) {
			wordlist.splice(index,0,w);
		}
	}
	
	/*
	 * 获取方法名称
	 * */
	b.getFunScopeName=function(wordList,index)
	{
		var len = wordList.length;
		var nextword = index<len?wordList[index+1]:null;
		var nextNextWord = index+1<len?wordList[index+2]:null;
		if(nextword && nextNextWord && nextword.content!="(" && nextNextWord.content == "(")
		{
			//识别正规方法名写法function funName(){}
			return nextword.content;
		}
		else
		{
			var prevword = index>0?wordList[index-1]:null;
			var prevPrevWord = index-1>0?wordList[index-2]:null;
			var prevPrevPrevWord = index-2>0?wordList[index-3]:null;
			if(prevword && prevPrevWord && prevword.content =="=" &&
			(prevPrevPrevWord && (prevPrevPrevWord.content =="var" || prevPrevPrevWord.content ==".")
			|| !prevPrevPrevWord))
			{
				//暂时识别写法var funName = function(){}
				return prevPrevWord.content;
			}
			else if(prevword && prevPrevWord && prevPrevPrevWord &&
			prevword.content ==":" && (prevPrevPrevWord.content =="," || prevPrevPrevWord.content =="{"))
			{
				//暂时识别写法{funName:function(){}}
				return prevPrevWord.content;
			}
		}
		return "";
	}
	
	/*
	 * 获取方法名称
	 * */
	b.getClsScopeName=function(wordList,index)
	{
		var len = wordList.length;
		var nextword = index<len?wordList[index+1]:null;
		var nextNextWord = index+1<len?wordList[index+2]:null;
		if(nextword && nextNextWord && nextword.content!="(" && nextNextWord.content == "{" || nextNextWord.content == "extends")
		{
			//识别正规方法名写法class clsName{}
			return nextword.content;
		}
		else
		{
			var prevword = index>0?wordList[index-1]:null;
			var prevPrevWord = index-1>0?wordList[index-2]:null;
			var prevPrevPrevWord = index-2>0?wordList[index-3]:null;
			if(prevword && prevPrevWord && prevword.content =="=" &&
			(prevPrevPrevWord && (prevPrevPrevWord.content =="var" || prevPrevPrevWord.content ==".")
			|| !prevPrevPrevWord))
			{
				//暂时识别写法var clsName = class {}
				return prevPrevWord.content;
			}
			else if(prevword && prevPrevWord && prevPrevPrevWord &&
			prevword.content ==":" && (prevPrevPrevWord.content =="," || prevPrevPrevWord.content =="{"))
			{
				//暂时识别写法{clsName:class{}}
				return prevPrevWord.content;
			}
		}
		return "";
	}
	
	b.analyseScope=function (wordList,sta,topScope) {
		var l = wordList.length;
		var currentScope = topScope;
		
		for (var i = sta; i < l; i++ ) {
			var nextword = i<l-1?wordList[i+1]:null;
			var lastword = i > 0?wordList[i-1]:null;
			//var lastlastword = i > 1?wordList[i-2]:null;
			var curword = wordList[i];
			var word = wordList[i].content;
			
			if (curword.type == WordType.CONSTANT) continue;
			
			if (word == "class") {
				//新开一个域
				let className = this.getClsScopeName(wordList,i);
				if(className)
				{
					var scope = new ScopeVO();
					scope.name = className;
					scope.params = [];
					scope.word = curword;
					scope.scopeType = ScopeVO.SCOPE_CLASS;
					scope.sta = i;
					if (currentScope) {
						if (!currentScope.childrens) {
							currentScope.childrens = [];
						}
						scope.parent = currentScope;
						currentScope.childrens.push(scope);
					}
					currentScope = scope;
				}
			}
			else if (word == "function") {
				//新开一个域
				var scope = new ScopeVO();
				scope.name = this.getFunScopeName(wordList,i);
				scope.params = [];
				scope.word = curword;
				scope.scopeType = ScopeVO.SCOPE_FUNCTION;
				scope.sta = i;
				if (currentScope) {
					if (!currentScope.childrens) {
						currentScope.childrens = [];
					}
					scope.parent = currentScope;
					currentScope.childrens.push(scope);
				}
				currentScope = scope;
			}
			else if(currentScope.scopeType == ScopeVO.SCOPE_CLASS && curword.type == WordType.SYMBOL && nextword && nextword.content=="(")
			{
				//在class 定义下，xx()写法都是方法声明
				//新开一个域
				var scope = new ScopeVO();
				scope.name = word;
				scope.params = [];
				scope.word = curword;
				scope.scopeType = ScopeVO.SCOPE_FUNCTION;
				scope.sta = i;
				if (currentScope) {
					if (!currentScope.childrens) {
						currentScope.childrens = [];
					}
					scope.parent = currentScope;
					currentScope.childrens.push(scope);
				}
				currentScope = scope;
			}
			else if (word == "if" || word == "switch" || word == "for" || word == "while" || word == "do" || word == "try" || word == "else" ||word=="catch"
			//|| word == "with" 不支持with语句
			) {
				if (word == "else" && nextword && (nextword.content == "if" ||nextword.content!="{")) {
					//else if 忽略此次else
					//或者else 的单行语句没有域
					continue;
				}else if (word == "while" && currentScope && currentScope.childrens) {
					var word2 = currentScope.childrens[currentScope.childrens.length - 1].word;
					if(word2.content == "do"){
						//do语句的while结尾，while没有域
						continue;
					}
				}
				
				//新开一个域
				scope = new ScopeVO();
				scope.params = [];
				scope.word = curword;
				scope.scopeType = ScopeVO.SCOPE_TOKEN;
				scope.sta = i;
				if (currentScope) {
					if (!currentScope.childrens) {
						currentScope.childrens = [];
					}
					scope.parent = currentScope;
					currentScope.childrens.push(scope);
				}
				currentScope = scope;
			}
			else if (
			lastword && curword.type != WordType.OPTION && ((lastword.content == "var" || lastword.content == "const" || lastword.content == "let" || lastword.content == "function") || (nextword&&lastword.content!="."&&nextword.content=="="))
			) {
				if (nextword && lastword.content != "var" && lastword.content != "const" && lastword.content != "let" && lastword.content != "," && lastword.content != "." && nextword.content == "=") {
					var ptso = this.findContainParam(currentScope, curword);
					this.addScopeParam(ptso||topScope,curword,0);
				}else if (currentScope) {
					ptso = currentScope;
					if (lastword.content == "function") {
						ptso = currentScope.parent;
					}else if (lastword.content != "var" && lastword.content != "const") {
						currentScope.definingVar = true;
					}
					//记录到function参数中，不能在if、while中
					this.addScopeParam(ptso,curword,ScopeVO.SCOPE_FUNCTION|ScopeVO.SCOPE_MAIN);
				}
			}else if (word == 'return') {
				if (curword.nextCRLF && nextword && nextword.content != ";" && nextword.type!=WordType.OPTION) {
					this.addConlion(wordList,i+1);
					l++;
					i++;
				}
			}else if (word == 'this') {
				//记录this为临时对象
				//if (nextword && nextword.content == "." && nextword.type==WordType.OPTION) {
					ptso = this.getFunScope(currentScope);
					if (ptso) {
						ptso.hasThis=true;
						this.addScopeParam(ptso, curword, 0);
					}
				//}
			}else if (word == 'eval') {
				ptso = this.getFunScope(currentScope);
				if (ptso) {
					ptso.hasEval = true;
				}
			}
			
			if (currentScope) {
				if(word == "(") {
					//参数开始
					currentScope.smallStaCount++;
				}else if (word == ',') {
					//添加参数
					if (currentScope.smallEndCount - currentScope.smallStaCount == -1 && currentScope.bigStaCount == 0 &&
						lastword && lastword.type == WordType.SYMBOL && currentScope.scopeType==ScopeVO.SCOPE_FUNCTION) {
						this.addScopeParam(currentScope,lastword,ScopeVO.SCOPE_FUNCTION);
					}else if (currentScope.smallEndCount - currentScope.smallStaCount == 0) {
						if(currentScope.definingVar){
							//排除方法调用的参数,号隔开形式
							var nnextword = i<l-2?wordList[i+2]:null;
							if (nnextword && nextword.type == WordType.SYMBOL){
								if (nnextword.type == WordType.OPTION && (nnextword.content == ","  || nnextword.content == ";")){
									//通过,号连续声明的普通变量
									this.addScopeParam(currentScope,nextword,ScopeVO.SCOPE_FUNCTION|ScopeVO.SCOPE_MAIN);
								}else if (nextword.nextCRLF  && nnextword.type != WordType.OPTION){
									//通过,号连续声明的普通变量，回车结束声音的变量
									this.addScopeParam(currentScope,nextword,ScopeVO.SCOPE_FUNCTION|ScopeVO.SCOPE_MAIN);
								}
							}
						}
					}
				}else if (word == ")") {
					
					//参数结束
					currentScope.smallEndCount++;
					
					if (currentScope.smallEndCount - currentScope.smallStaCount == 0 ) {
						if(currentScope.bigStaCount==0){
							if (currentScope.scopeType == ScopeVO.SCOPE_FUNCTION && lastword.type != WordType.OPTION) {
								//声明方法参数
								this.addScopeParam(currentScope,lastword,ScopeVO.SCOPE_FUNCTION);
							}
							if (currentScope.word && currentScope.word.content == "if" && nextword && nextword.content!="{") {
								//if 的单行语句,返回父域
								//currentScope.end = i;
								currentScope = currentScope.parent;
							}else if (currentScope.word && currentScope.word.content == "for" && nextword && nextword.content!="{") {
								//for 的单行语句,返回父域
								//currentScope.end = i;
								currentScope = currentScope.parent;
							}
						}else {
							//非声明参数、方法时使用结束符，只是是被调用方法结束符
							if (nextword && nextword.type != WordType.OPTION) {
								curword.type = ScriptWord.CONNECTWORD;
							}
						}
						
					}
				}else if (word == '{') {
					currentScope.bigStaCount++;
					if (currentScope.smallEndCount-currentScope.smallStaCount == 0 && currentScope.bigEndCount - currentScope.bigStaCount == -1) {
						//区域内开始
						currentScope.codeSta = i;
					}
				}else if (word == '}') {
					if (lastword && lastword.content == ";" && lastword.type == WordType.OPTION) {
						//遇到;}这种情况，去掉;号
						wordList.splice(i - 1, 1);
						i--;
						l--;
					}
					currentScope.bigEndCount++;
					if ((currentScope.scopeType == ScopeVO.SCOPE_TOKEN ||currentScope.scopeType == ScopeVO.SCOPE_FUNCTION)&& currentScope.smallEndCount - currentScope.smallStaCount == 0 && currentScope.bigEndCount - currentScope.bigStaCount == 0) {
						//区域内结束
						currentScope.end = i;
						if (currentScope.scopeType == ScopeVO.SCOPE_FUNCTION) {
							if (currentScope.sta && wordList[currentScope.sta - 1].content != "=") {
								curword.type = WordType.OPTION;
								if (nextword && nextword.content == ";" && nextword.type == WordType.OPTION) {
									//去掉域}后跟着的;号
									wordList.splice(i+1, 1);
									l--;
								}
							}else {
								curword.type = ScriptWord.CONNECTWORD;
							}
							//curword.type = ScriptWord.CONNECTWORD;
							//var f=function(){};这种情况必须;结尾
						}else {
							if (currentScope.scopeType == ScopeVO.SCOPE_TOKEN && nextword && nextword.content == ";" && nextword.type == WordType.OPTION) {
								//去掉if while for等语句}后跟着的;号
								wordList.splice(i+1, 1);
								l--;
							}
						}
						if(currentScope.scopeType!=ScopeVO.SCOPE_MAIN){
							currentScope = currentScope.parent;
						}
					}else {
						//非语句域内结束符，只是变量{}结束符
						curword.type = ScriptWord.CONNECTWORD;
					}
				}
				else if (word == ']') {
					if (nextword && nextword.content != ";" && nextword.type!=WordType.OPTION) {
						this.addConlion(wordList,i+1);
						l++;
						i++;
					}
				}
				
				if (currentScope.definingVar) {
					if (word == "=" || word==";") {
						currentScope.definingVar = false;
					}
				}
			}
		}
		
		topScope.sta = 0;
		topScope.end = wordList.length - 1;
		return wordList;
	}
	
	b.getPositionByScope = function(bigScope,wordList,selWordContent,selWordStart,selWordIndex)
	{
		if(bigScope.sta <= selWordIndex && bigScope.end >= selWordIndex)
		{
			var childrens = bigScope.childrens;
			if(childrens)
			{
				//找子域参数
				var clen = childrens.length;
				for(var i=0;i<clen;i++)
				{
					var scope = childrens[i];
					var result = this.getPositionByScope(scope,wordList,selWordContent,selWordStart,selWordIndex);
					if(result)
					{
						return result;
					}
				}
			}
			var params = bigScope.params;
			if(params)
			{
				clen = params.length;
				for(i=0;i<clen;i++)
				{
					var word = params[i];
					if(word.content == selWordContent)
					{
						//找到一个声明处
						return word;
					}
				}
			}
			if(childrens)
			{
				//找子域名称
				clen = childrens.length;
				for(i=0;i<clen;i++)
				{
					scope = childrens[i];
					if(scope.name == selWordContent)
					{
						return scope.word;
					}
				}
			}
		}
		return null;
	}
	
	/**
	* 返回关键字的声明处的位置
	*/
	b.jumpToDeclare = function(script,anchor)
	{
		var wordList = this.getWords(script);
		var l = wordList.length;
		var delWord = null;
		var selWord = null;
		var wordIndex = -1;
		for(var i=0;i<l;i++)
		{
			var word = wordList[i];
			var wSta = word.start;
			if(wSta == anchor)
			{
				selWord = word;
				wordIndex = i;
				break;
			}
			else if(wSta < anchor)
			{
				var wEnd = wSta + (word.content?word.content.length:0);
				if(wEnd >= anchor)
				{
					selWord = word;
					wordIndex = i;
					break;
				}
			}
		}
		if(selWord)
		{
			var topso = new ScopeVO();
			topso.scopeType = ScopeVO.SCOPE_MAIN;
			topso.bigStaCount = 1;
			topso.params = [];
			var wordList2 = this.analyseScope(wordList,0,topso);
			topso.bigEndCount = 1;
			delWord = this.getPositionByScope(topso,wordList,selWord.content,selWord.start,wordIndex);
			wordList2.length = 0;
		}
		wordList.length = 0;
		return delWord;
	}
	
	/*
	在代码开始位置添加变量指向this;
	剔除子域的params中含有this变量项
	*/
	b.cullThisParam=function(scope, wordList, shortname) {
		if (scope.hasThis && scope.scopeType == ScopeVO.SCOPE_FUNCTION) {
			if (wordList[scope.codeSta].content == "{") {
				//手动添加var X = this的临时变量
				//剔除子域的params中含有this变量的,并统一在域代码开始处添加var X = this
				wordList[scope.codeSta].content =  "{var " + shortname+"=this;";
			}
		}
		
		var arr = scope.childrens;
		if(arr){
			var l = arr.length;
			for (var i = 0; i < l; i++)
			{
				var so = arr[i];
				var arr2 = so.params;
				var jl = arr2.length;
				for (var j = 0; j < jl; j++) {
					var param = arr2[j];
					if (param.content == "this") {
						arr2.splice(j, 1);
						j--;
						jl--;
					}
				}
				this.cullThisParam(so, wordList, shortname);
			}
		}
	}
	
	/*
	 * 缩写临时变量和方法名
	 * */
	b.shortTmpName=function(scope, wordList, kisUnID,nousename_arr) {
		if(scope.scopeType != ScopeVO.SCOPE_MAIN && !scope.hasEval){
			var arr = scope.params;
			var l = arr.length;
			var sta = scope.sta;
			var end = scope.end;
			for (var i = 0; i < l; i++) 
			{

				var p = arr[i];
				
				if (p.hasSort) continue;
				
				var shortname = this.getSortNameByID(kisUnID++);
				while (nousename_arr && nousename_arr.indexOf(shortname)!=-1) {
					shortname = this.getSortNameByID(kisUnID++);
				}
				
				var oriName = p.content;
				p.content = shortname;
				p.hasSort = true;
				
				if (oriName == "this") {
					this.cullThisParam(scope, wordList,  shortname);
				}
				
				for (var j = sta; j <= end; j++) {
					var word = wordList[j];
					if (word.type != WordType.CONSTANT && word.content == oriName && !word.hasSort ) {
						var lastword = j > 0?wordList[j - 1]:null;
						var nextword = j < end-1?wordList[j + 1]:null;
						
						if (lastword && !(lastword.type == WordType.OPTION && lastword.content == ".")) {
							
							if (nextword && lastword.type == WordType.OPTION && (lastword.content == "," || lastword.content == "{") && nextword.type == WordType.OPTION && nextword.content == ":") {
								//可能是普通对象声明{n:1,n:2}
								continue;
							}
							
							//if (oriName == "this" && nextword.content != ".") {
								////没有点号在后的this变量，不用缩写
								//continue;
							//}
							
							//没有点号在前的视为临时变量可缩写此变量名
							
							word.content = shortname;
							word.hasSort = true;
						}
					}
				}
			}
		}
		var arr2 = scope.childrens;
		if(arr2){
			l = arr2.length;
			for (i = 0; i < l; i++)
			{
				var so = arr2[i];
				this.shortTmpName(so, wordList, kisUnID,nousename_arr);
			}
		}
	}
	
	b.join=function(words){
		var str = "";
		var jl = words.length;
		for (var j = 0; j < jl; j++) {
			var word = words[j];
			var nextword = j<jl-1?words[j+1]:null;
			var lastword = j > 0?words[j - 1]:null;
			
			var wordContent = word.content;
			
			if (word.kind == JSScript.JS_String_0) {
				var nnextword = j<jl-2?words[j+2]:null;
				var llastword = j>1?words[j-2]:null;
				var hl=false, hn = false;
				hn = nextword && nnextword && nextword.content == "+" && nextword.type == WordType.OPTION && nnextword.kind == JSScript.JS_String_1;
				hl = lastword && llastword && lastword.content == "+" && lastword.type == WordType.OPTION && llastword.kind == JSScript.JS_String_1;
				if (hl && hn) {
					str += wordContent;
					j++;
				}else if(hl){
					str += wordContent + '\'';
				}else if (hn) {
					j++;
					str += '\''+wordContent;
				}else {
					str +='\''+wordContent+ '\'';
				}
			}else if (word.kind == JSScript.JS_String_1) {
				nnextword = j<jl-2?words[j+2]:null;
				llastword = j > 1?words[j - 2]:null;
				hl=false, hn = false;
				hn = nextword && nnextword && nextword.content == "+" && nextword.type == WordType.OPTION && nnextword.kind == JSScript.JS_String_1;
				hl = lastword && llastword && lastword.content == "+" && lastword.type == WordType.OPTION && llastword.kind == JSScript.JS_String_1;
				if (hl && hn) {
					str += wordContent;
					j++;
				}else if(hl){
					str += wordContent + '"';
				}else if (hn) {
					j++;
					str += '"'+wordContent;
				}else {
					str +='"'+wordContent+ '"';
				}
			}else {
				if ((wordContent=="--"||wordContent=="++") && lastword && lastword.content!=";" &&lastword.nextCRLF && nextword && nextword.type!=WordType.OPTION) {
					//自加减1情况在前
					//添加分号;
					str += ";";
				}
				str += wordContent;
			}
			
			if ((this.connectSymbols.indexOf(wordContent) != -1 || (nextword && (this.middleConnectOptions.indexOf(nextword.content)!=-1)))
				&&nextword &&!(nextword.type==WordType.OPTION && nextword.content==";")) {
				if (word.type == WordType.SYMBOL && nextword.type == WordType.OPTION&&
				((wordContent == "function" && nextword.content == "(")||
				(wordContent == "return" && nextword.content == "}")||
				(wordContent == "else" && nextword.content == "{"))
				){
					continue;
				}
				
				str += " ";
			}else if (
			word.type != WordType.OPTION && nextword && nextword.type != WordType.OPTION
			&& word.nextCRLF//必须原文本身就回车在两词的中间
			&& !(word.kind == ScriptWord.KEYWORD && nextword.kind == ScriptWord.KEYWORD)
			&& nextword.content != "}"
			&& nextword.content != ")"
			&& nextword.content != "]"
			) {
				//添加分号;
				str += ";";
			}else if (wordContent=="--"||wordContent=="++") {
				if (lastword && lastword.type != WordType.OPTION && word.nextCRLF && nextword&&nextword.content!=";") {
					//自加减1情在后
					//添加分号;
					str += ";";
				}
			}
		}
		
		if (!(word.content == ";" && word.type == WordType.OPTION)) {
			//最后加;号
			str += ";";
		}
		return str;
	}
		
	b.joinNormal = function(words){
		var str = "";
		var jl = words.length;
		var curRow = 0;
		for (var j = 0; j < jl; j++) {
			var word = words[j];
			
			var wordContent = word.content;
			if (word.row > curRow)
			{
				str += "\r";
				curRow = word.row;
			}
			if (word.kind == JSScript.JS_String_0) {
				str +='\''+wordContent+ '\'';
			}else if (word.kind == JSScript.JS_String_1) {
				str +='"'+wordContent+ '"';
			}else {
				str += wordContent;
			}
		}
		return str;
	}
	
	b.findContainParam =function(scope, param) {
		var ptso = scope;
		var pcontant = param.content;
		while (ptso) {
			if (ptso.scopeType==ScopeVO.SCOPE_FUNCTION) {
				var arr = ptso.params;
				var l = arr.length;
				for (var i = 0; i < l; i++)
				{
					var im = arr[i];
					if (im.content == pcontant) {
						return ptso;
					}
				}
			}
			ptso = ptso.parent;
		}
		return null;
	}
	
	b.getFunScope=function(scope) 
	{
		var ptso = scope;
		while (ptso) {
			if (ptso.scopeType==ScopeVO.SCOPE_FUNCTION) {
				break;
			}
			ptso = ptso.parent;
		}
		return ptso;
	}
	
	b.addScopeParam =function (scope, param, tofunction) {
		var ptso = scope;
		if (tofunction) {
			while (ptso) {
				if (ptso.scopeType==ScopeVO.SCOPE_FUNCTION || ptso.scopeType==ScopeVO.SCOPE_TOKEN  || ptso.scopeType==ScopeVO.SCOPE_MAIN) {
					break;
				}
				ptso = ptso.parent;
			}
			
		}
		if(ptso){
			var arr = ptso.params;
			var l = arr.length;
			var pcontant = param.content;
			for (var i = 0; i < l; i++)
			{
				var im = arr[i];
				if (im.content == pcontant) {
					return;
				}
			}
			arr.push(param);
		}
	}

	kiscompress.JSScript = JSScript;
})()